﻿/// <reference path="../devextreme/ts/jquery.d.ts" />

(function () {
    window.yakeji = window.yakeji || {};

    window.yakeji.showLoading = () => {
        const $body = $(document.body);
        let $loading = $('body > .yakeji-loading');
        if ($loading.length === 0) {
            $loading = $('<div class="yakeji-loading"><div class="background"></div><div class="indicator"></div></div>').appendTo($body);
        } else {
            if (window.yakeji.hideLoadingTimer) {
                clearTimeout(window.yakeji.hideLoadingTimer);
            }
        }
        setTimeout(() => {
            $loading.addClass('show');
            $('body > .yakeji-loading > .indicator').dxLoadIndicator({
                height: 50,
                width: 50,
            });
        }, 500);
    }

    window.yakeji.hideLoading = () => {
        window.yakeji.hideLoadingTimer = setTimeout(() => {
            $('body > .yakeji-loading').remove();
        }, 200);
    }
})();